var loginname = GetQueryString("loginname");
if (loginname == "") {
    //UIkit.modal.alert("用户名为空");
    window.location.href = "resetpwd1.html";
}

var email = sessionStorage.getItem(loginname + "code");
if (email == null) {
    window.location.href = "resetpwd1.html";
}

$(function () {

    $(".inputClass").blur(function () {
        var id = $(this).attr("id");//获取当前输入框的id  
        var funName = "validate" + id.substring(0, 1).toUpperCase() + id.substring(1) + "()";//得到对应的校验函数名  
        eval(funName);//执行函数调用  
    });

});

$("#btnSetpwd").click(function () {
    var bool = true;//表示校验通过  
    var code = $("#newpwd").val();
    if (code == null || code == undefined || code == '') {
        UIkit.modal.alert("新密码不能为空");
        return;
    }
    if (code.length < 3 || code.length > 20) {
        /*  
         * 获取对应的label  
         * 添加错误信息  
         * 显示label  
         */
        UIkit.modal.alert("密码长度必须在3 ~ 20之间！");

        return false;
    }

    $.ajax({
        type: "Post",
        url: GetBaseUrl() + "/users/password",
        dataType: "json",
        data:{loginname:loginname,loginpass:code},
        success: function (msg) {
            if (msg.code == 0) {
                sessionStorage.removeItem(loginname+"code");

                window.location.href = "login.html";
            }
            else {
                UIkit.modal.alert(msg.msg);
            }
        },
       error: function (XMLHttpRequest, textStatus, errorThrown) {
            UIkit.modal.alert("服务异常");
        }
    });

})